Get volume name also on Win9x. (#301798, Daniel Atallah)
authorTor Lillqvist <tml@novell.com>
Mon, 25 Apr 2005 00:47:31 +0000 (00:47 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Mon, 25 Apr 2005 00:47:31 +0000 (00:47 +0000)
2005-04-25  Tor Lillqvist  <tml@novell.com>

* gtk/gtkfilesystemwin32.c
(gtk_file_system_win32_volume_get_display_name): Get volume name
also on Win9x. (#301798, Daniel Atallah)
(canonicalize_filename): Add explicit braces to silence compiler
warning.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkfilesystemwin32.c

index 137d569d8ae65145bba19928b5e00a21978417e0..f879e57fc7445074bad39a92f5ec7c18fb1af83d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-04-25  Tor Lillqvist  <tml@novell.com>
+
+       * gtk/gtkfilesystemwin32.c
+       (gtk_file_system_win32_volume_get_display_name): Get volume name
+       also on Win9x. (#301798, Daniel Atallah)
+       (canonicalize_filename): Add explicit braces to silence compiler
+       warning.
+
 2005-04-22  Tor Lillqvist  <tml@novell.com>
 
        * gtk/gtkmain.c: Initailize gettext before use. Calling
index 137d569d8ae65145bba19928b5e00a21978417e0..f879e57fc7445074bad39a92f5ec7c18fb1af83d 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-25  Tor Lillqvist  <tml@novell.com>
+
+       * gtk/gtkfilesystemwin32.c
+       (gtk_file_system_win32_volume_get_display_name): Get volume name
+       also on Win9x. (#301798, Daniel Atallah)
+       (canonicalize_filename): Add explicit braces to silence compiler
+       warning.
+
 2005-04-22  Tor Lillqvist  <tml@novell.com>
 
        * gtk/gtkmain.c: Initailize gettext before use. Calling
index 137d569d8ae65145bba19928b5e00a21978417e0..f879e57fc7445074bad39a92f5ec7c18fb1af83d 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-25  Tor Lillqvist  <tml@novell.com>
+
+       * gtk/gtkfilesystemwin32.c
+       (gtk_file_system_win32_volume_get_display_name): Get volume name
+       also on Win9x. (#301798, Daniel Atallah)
+       (canonicalize_filename): Add explicit braces to silence compiler
+       warning.
+
 2005-04-22  Tor Lillqvist  <tml@novell.com>
 
        * gtk/gtkmain.c: Initailize gettext before use. Calling
index 2824920e1995d535d00f57d4a4e428b3f67f23e3..8d3ebb656901ab254d717bfa353b26230b9307d3 100644 (file)
@@ -612,23 +612,48 @@ gtk_file_system_win32_volume_get_display_name (GtkFileSystem       *file_system,
   else if ((filename_is_drive_root (volume->drive) && volume->drive[0] >= 'C') ||
       volume->drive_type != DRIVE_REMOVABLE)
     {
-      gunichar2 *wdrive = g_utf8_to_utf16 (volume->drive, -1, NULL, NULL, NULL);
-      gunichar2 wname[80];
-      if (GetVolumeInformationW (wdrive,
-                                wname, G_N_ELEMENTS(wname), 
-                                NULL, /* serial number */
-                                NULL, /* max. component length */
-                                NULL, /* fs flags */
-                                NULL, 0) /* fs type like FAT, NTFS */ &&
-         wname[0])
+      gchar *name = NULL;
+      if (G_WIN32_HAVE_WIDECHAR_API ())
        {
-         gchar *name = g_utf16_to_utf8 (wname, -1, NULL, NULL, NULL);
+         gunichar2 *wdrive = g_utf8_to_utf16 (volume->drive, -1, NULL, NULL, NULL);
+         gunichar2 wname[80];
+         if (GetVolumeInformationW (wdrive,
+                                    wname, G_N_ELEMENTS(wname), 
+                                    NULL, /* serial number */
+                                    NULL, /* max. component length */
+                                    NULL, /* fs flags */
+                                    NULL, 0) /* fs type like FAT, NTFS */ &&
+             wname[0])
+           {
+             name = g_utf16_to_utf8 (wname, -1, NULL, NULL, NULL);
+           }
+         g_free (wdrive);
+       }
+      else
+        {
+          gchar *cpdrive = g_locale_from_utf8 (volume->drive, -1, NULL, NULL, NULL);
+          gchar cpname[80];
+          if (GetVolumeInformationA (cpdrive,
+                                    cpname, G_N_ELEMENTS(cpname), 
+                                    NULL, /* serial number */
+                                    NULL, /* max. component length */
+                                    NULL, /* fs flags */
+                                    NULL, 0) /* fs type like FAT, NTFS */ &&
+             cpname[0])
+            {
+              name = g_locale_to_utf8 (cpname, -1, NULL, NULL, NULL);
+            }
+          g_free (cpdrive);
+        }
+      if (name != NULL)
+        {
          real_display_name = g_strdup_printf (_("%s (%s)"), name, volume->drive);
          g_free (name);
        }
       else
-       real_display_name = g_strdup (volume->drive);
-      g_free (wdrive);
+       {
+         real_display_name = g_strdup (volume->drive);
+       }
     }
   else
     real_display_name = g_strdup (volume->drive);
@@ -741,7 +766,7 @@ canonicalize_filename (gchar *filename)
   printf("canonicalize_filename: %s ", filename);
 #endif
 
-  past_root = g_path_skip_root (filename);
+  past_root = (gchar *) g_path_skip_root (filename);
 
   q = p = past_root;
 
@@ -1287,10 +1312,12 @@ gtk_file_system_win32_render_icon (GtkFileSystem     *file_system,
     }
 
   if (!icon_set)
-    if (g_file_test (filename, G_FILE_TEST_IS_EXECUTABLE))
-       icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_EXECUTE);
-    else
-      icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_FILE);
+    {
+      if (g_file_test (filename, G_FILE_TEST_IS_EXECUTABLE))
+        icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_EXECUTE);
+      else
+        icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_FILE);
+    }
 
   // FIXME : I'd like to get from pixel_size (=20) back to
   // icon size, which is an index, but there appears to be no way ?